{{ if and (not (eq .Site.DisqusShortname "")) (and (not .Params.disable_comments) (or (eq .Kind "404") (and (not .IsHome) .Content))) }}
<section class="comments">
  <div id="disqus_thread"></div>
  <script>
  var disqus_config = function () {
  };
  (function() {
    var inIFrame = function() {
      var iframe = true;
      try { iframe = window.self !== window.top; } catch (e) {}
      return iframe;
    };
    if (inIFrame()) return;
    var disqus_js = '//{{ .Site.DisqusShortname }}.disqus.com/embed.js';
    var d = document, s = d.createElement('script');
    s.src = disqus_js; s.async = true;
    s.setAttribute('data-timestamp', +new Date());
    var b = false, l = function() {
      if (b) return;
      (d.head || d.body).appendChild(s); b = true;
    }
    var t = d.getElementById('disqus_thread');
    s.onerror = function(e) {
      if (sessionStorage.getItem('failure-note')) return;
      t.innerText = '非常抱歉, 中国大陆地区读者需要翻墙才能发表评论。';
      t.style.border = '1px dashed';
      t.style.padding = '.5em';
      t.style.background = 'lightyellow';
      sessionStorage.setItem('failure-note', true);
    };
    // show comments when the hash means to jump to a comment
    if (location.hash.match(/^#comment/)) return l();
    var c = function() {
      if (b) return;
      var rect = t.getBoundingClientRect();
      if (rect.top < window.innerHeight && rect.bottom >= 0) l();
    };
    window.addEventListener('load', c);
    d.addEventListener('scroll', c);
  })();
  </script>
  <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</section>
{{ end }}
